package com.health.patient.server.controller;

import com.health.common.core.domain.R;
import com.health.common.core.web.domain.AjaxResult;
import com.health.health.common.dto.PmsPatientRecordDto;
import com.health.patient.server.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("/patient")
public class GroupController {

    @Autowired
    private PatientService patientService;


    /**
     * 查询患者分组列表
     * @return
     * ybz
     */
    @GetMapping("/getPatientGroupList")
    public AjaxResult getPatientGroupList(){
        return patientService.getPatientGroupList();
    }

    /**
     * 医生添加自己的分组
     * @param groupName
     * @return
     * ybz
     */
    @PutMapping("/addPatientGroup")
    public AjaxResult addPatientGroup(@RequestParam String groupName){
        return patientService.addPatientGroup(groupName);
    }

    /**
     * 医生删除自己的分组
     * @param groupId
     * @return
     * ybz
     */
    @DeleteMapping("/deletePatientGroup/{groupId}")
    public AjaxResult deletePatientGroup(@PathVariable Long groupId){
        return patientService.deletePatientGroup(groupId);
    }

    /**
     * 查询分组内患者列表
     * @param groupId
     * @return
     * ybz
     */
    @GetMapping("getPatientList/{groupId}")
    public AjaxResult getPatientList(@PathVariable Long groupId){
        return patientService.getPatientListByGroupId(groupId);
    }

    /**
     * 修改患者的分组信息
     * @param patientRecordId
     * @param groupIds
     * @return
     * ybz
     */
    @PutMapping("updatePatientGroup/{patientRecordId}/{groupIds}")
    public AjaxResult updatePatientGroup(@PathVariable Long patientRecordId,@PathVariable String groupIds){
        return patientService.updatePatientGroup(patientRecordId,groupIds);
    }


    /**
     * 添加患者
     * @param patientRecordDto
     * @return ybz
     */
    @PostMapping("/addPatientRecord")
    public R addPatientRecord(@RequestBody PmsPatientRecordDto patientRecordDto){
        return patientService.addPatientRecord(patientRecordDto);
    }

}
